import React, { useState } from 'react'
import Taro from '@tarojs/taro'
import { View, Text, Image ,Swiper,SwiperItem,showToast} from '@tarojs/components'

import ShowCart from "../../components/showcart";

import './index.scss'

function Mine (){
  const [mineData,useMineData] = useState({
      mineData:[{mineUrl: require('../../static/images/daifuk.png'),txt:'待付款'},
        {mineUrl: require('../../static/images/daishouh.png'),txt:'待发货'},
        {mineUrl: require('../../static/images/pingjia.png'),txt:'待收货'},
        {mineUrl: require('../../static/images/dingdan.png'),txt:'我的订单'},],
    mineList: [
      {listUrl: require('../../static/images/yyt.png'), txt:'我的拼团'},
      {listUrl: require('../../static/images/yyt.png'), txt:'消息中心'},
      {listUrl: require('../../static/images/yyt.png'), txt:'收货地址'},
      {listUrl: require('../../static/images/yyt.png'), txt:'联系客服'},
    ],
    orderSwiper:[
        {orderUrl: require('../../static/images/banner2.png')},
        {orderUrl: require('../../static/images/banner2.png')},
        {orderUrl: require('../../static/images/banner2.png')},
        {orderUrl: require('../../static/images/banner2.png')}
    ]
    }
  )
  // const [orderSwiper, useOrderSwiper] = useState([
  //   {orderUrl: require('../../static/images/banner2.png')},
  //   {orderUrl: require('../../static/images/banner2.png')},
  //   {orderUrl: require('../../static/images/banner2.png')},
  //   {orderUrl: require('../../static/images/banner2.png')}
  // ])

  // const [mineList,useMineList] = useState([
  //   {listUrl: require('../../static/images/yyt.png'), txt:'我的拼团'},
  //   {listUrl: require('../../static/images/yyt.png'), txt:'消息中心'},
  //   {listUrl: require('../../static/images/yyt.png'), txt:'收货地址'},
  //   {listUrl: require('../../static/images/yyt.png'), txt:'联系客服'},
  // ])
  function toNewPages(txt){
    let url;
    switch (txt){
      case '消息中心':
        url = '/pages/noticemsg/index'
        break
      case '我的拼团':
        url = '/pages/mine/myfavorites/index'
        break
      case '收货地址':
        url = '/pages/address/index'
        break
      case '联系客服':
        url = ''
        break
      case '关于我们':
        url = ''
        break
    }
    Taro.navigateTo({
      url
    })
  }
  // 前往个人信息页面
  function goTobinDingInfo(){
    Taro.navigateTo({
      url: '/pages/mine/bindinginfo/index'
    })
  }
  function goToOrder(info){
    if(info === '待评价'){
      Taro.navigateTo({
        url: '/pages/mine/myevaluation/index'
      })
    }else{
      Taro.navigateTo({
        url: '/pages/mine/myorder/index'
      })
    }
  }
  return (
    <View className='mine'>
      <View className='mine_info' onClick={() => {goTobinDingInfo()}}>
        <View className='mine_img'>
          <Image className='mine_info_img' src={require('../../static/images/user.png')} />
        </View>
        <Text className='mine_login'>登录/注册</Text>
      </View>
      {/*我的订单*/}
      <View className='user_order'>
        <View className='order_top'> 我的订单 </View>
        <View style={{display:'flex', justifyContent: 'space-around'}}>
          {
            mineData.mineData.map((item,index) => {
              return (
                <View className='user_order_item' onClick={() => {goToOrder(item.txt)}}>
                  <Image  className='order_item_img' src={item.mineUrl} />
                  <Text className='order_item_info'>{item.txt}</Text>
                </View>
              )
            })
          }
        </View>
      </View>
      {/*广告轮播区域*/}
      {/*<Swiper*/}
      {/*  indicatorDots*/}
      {/*  autoplay*/}
      {/*  circular*/}
      {/*  interval={3000}*/}
      {/*  className='order_swiper'>*/}
      {/*  {*/}
      {/*    mineData.orderSwiper.map((val,index) => {*/}
      {/*      return (*/}
      {/*        <SwiperItem className='order_swiper_item' key={index}>*/}
      {/*          <Image style={{width:'94%',height:'100%',borderRadius: '10px'}} src={val.orderUrl} />*/}
      {/*        </SwiperItem>*/}
      {/*      )*/}
      {/*    })*/}
      {/*  }*/}
      {/*</Swiper>*/}

      {/*操作列表*/}
      <View className='mine_list'>
        {
          mineData.mineList.map((mine,index) => {
            return (
              <View className='mine_item' key={index} onClick={() => {toNewPages(mine.txt)}}>
                <Text className='mine_item_txt'>{mine.txt}</Text>
                <Image className='mine_item_img' src={mine.listUrl} />
              </View>
            )
          })
        }
      </View>
    </View>
  )
}
export default Mine
